#include <iostream>
#include<exception>

class MyException:public std::exception
{
public:
    virtual const char *what()const noexcept
    {
        return "这是我自定义的异常";
    }

};


void func()
{
    throw MyException();
}

int main()
{
try
{
    func();
}
catch(const std::exception&e)
{
    std::cout<<e.what()<<'\n';
}

    return 0;
}